<template>
  <div>
    <el-row>
      <el-col :span="24">
        <div class="addccc">
          <div class="timeZone">
            <el-button
              type="primary"
              @click="newest(1)"
              icon="el-icon-circle-plus-outline"
              >新增拜访</el-button
            >
          </div>
          <div class="timeZone">
            <el-select v-model="screening" placeholder="单位筛选">
              <el-option
                v-for="item in UnitHealth"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </div>
          <div class="timeZone">
            <el-input
              style="width: 200px"
              v-model="global"
              placeholder="全局查询"
            ></el-input>
          </div>
          <div class="timeZone">
            <el-date-picker
              v-model="strtotime"
              type="datetimerange"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
            >
            </el-date-picker>
          </div>
          <div class="timeZone">
            <el-select
              v-model="timeout"
              placeholder="时间线"
              @change="disallow()"
            >
              <el-option
                v-for="item in newline"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </div>
        </div>
      </el-col>
      <el-col :span="24">
        <el-timeline v-if="timeout == 1">
          <el-timeline-item timestamp="2021年5月9日星期日" placement="top">
            <el-card>
              <h4>更新 Github 模板</h4>
              <p>王小虎 提交于 2018/4/12 20:46</p>
              <div>
                <el-button
                  size="mini"
                  @click="handleEdit(scope.$index, scope.row)"
                  >编辑</el-button
                >
                <el-button
                  size="mini"
                  type="danger"
                  @click="handleDelete(scope.$index, scope.row)"
                  >删除</el-button
                >
              </div>
            </el-card>
          </el-timeline-item>
          <el-timeline-item timestamp="2018/4/3" placement="top">
            <el-card>
              <h4>更新 Github 模板</h4>
              <p>王小虎 提交于 2018/4/3 20:46</p>
            </el-card>
          </el-timeline-item>
          <el-timeline-item timestamp="2018/4/2" placement="top">
            <el-card>
              <h4>更新 Github 模板</h4>
              <p>王小虎 提交于 2018/4/2 20:46</p>
            </el-card>
          </el-timeline-item>
        </el-timeline>
        <el-table :data="tableData" style="width: 100%" v-else>
          <el-table-column type="expand">
            <template #default="props">
              <el-form label-position="left" inline class="demo-table-expand">
                <el-form-item label="详情:">
                  <span>{{ props.row.name1 }}</span>
                </el-form-item>
                <el-form-item label="备注:">
                  <span>{{ props.row.name2 }}</span>
                </el-form-item>
              </el-form>
            </template>
          </el-table-column>
          <el-table-column label="单位" prop="name"> </el-table-column>
          <el-table-column label="联系人" prop="desc"> </el-table-column>
          <el-table-column label="拜访目的" prop="desc1"> </el-table-column>
          <el-table-column label="拜访时间" prop="desc2"> </el-table-column>
          <el-table-column label="所带产品" prop="desc3"> </el-table-column>
          <el-table-column label="拜访人" prop="desc4"> </el-table-column>
          <el-table-column label="同行者" prop="desc5"> </el-table-column>
          <el-table-column label="结果" prop="address"> </el-table-column>

          <el-table-column label="操作" width="240" align="center">
            <template #default="scope">
              <el-button
                size="mini"
                @click="handleEdit(scope.$index, scope.row)"
                >编辑</el-button
              >
              <el-button
                size="mini"
                type="danger"
                @click="handleDelete(scope.$index, scope.row)"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
    <el-dialog
      :title="single"
      v-model="plassets"
      width="45%"
      :close-on-click-modal="false"
    >
      <el-form ref="form" :inline="true" :model="form" label-width="100px">
        <el-form-item label="单位">
          <el-select
            style="width: 300px"
            v-model="form.unitshall"
            placeholder="请选择"
            clearable
          >
            <el-option
              v-for="item in funit"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="单位">
          <el-input v-model="form.contacts" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="拜访日期">
          <el-date-picker
            style="width: 300px"
            v-model="form.datetime"
            type="date"
            placeholder="选择日期"
            format="YYYY 年 MM 月 DD 日"
          >
            >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="拜访目的">
          <el-input v-model="form.visitor" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="所带产品">
          <el-input v-model="form.product" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="同伴">
          <el-input v-model="form.companion" style="width: 300px"></el-input>
        </el-form-item>
        <el-form-item label="详情">
          <el-input
            type="textarea"
            :rows="2"
            style="width: 300px"
            placeholder="请输入内容"
            v-model="form.details"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="拜访结果">
          <el-input
            type="textarea"
            :rows="2"
            style="width: 300px"
            placeholder="请输入内容"
            v-model="form.results"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input
            type="textarea"
            :rows="2"
            style="width: 300px"
            placeholder="请输入内容"
            v-model="form.newnotes"
          >
          </el-input>
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="plassets = false">取 消</el-button>
          <el-button type="primary" v-if="under == 1" @click="determine()"
            >确 定</el-button
          >
          <el-button @click="hardware()" v-else type="primary"
            >编辑 确 定</el-button
          >
        </span>
      </template>
    </el-dialog>
  </div>
</template>
<script>
export default {
  data() {
    return {
      timeout: "1", //时间线
      newline: [
        {
          value: "1",
          label: "时间线",
        },
        {
          value: "0",
          label: "表格",
        },
      ],
      global: "", //全局查询
      screening: "", //单位筛选
      strtotime: "", //开始结束时间
      UnitHealth: [],
      funit: [],
      form: {
        unitshall: "",
        contacts: "",
        datetime: "",
        visitor: "",
        product: "",
        companion: "",
        details: "",
        results: "",
        newnotes: "",
      },
      plassets: false,
      under: 1,
      single: "周报信息",
      tableData: [
        {
          name1:
            "由黄博士组织技术交流会。业主的需求点在于：螺栓预紧力，机匣的缺陷检测和应力检测。交流过程中发现，相关人员对残余应力的认识不足，认为零部件在运行中不存在残余应力。",
          name2: "",
          name: "贵阳航发",
          category: "黄菊",
          desc: "黄菊",
          desc1: "技术交流",
          desc2: "2021/5/22",
          desc3: "无",
          desc4: "方文平",
          desc5: "杨毅",
          address:
            "1）螺栓预紧力生成自主课题研究，预算300-400万；2）6月份安排超声探伤和残余应力现场检测演示。",
          shop: "xxxxx",
          shopId: "xxxxxx",
        },
      ],
    };
  },
  methods: {
    disallow() {
      console.log(this.timeout);
    },
    newest(index) {
      this.under = index;
      this.plassets = true;
    },
  },
};
</script>

<style >
.addccc {
  margin-bottom: 20px;
  margin-left: 20px;
  display: flex;
}
.timeZone {
  margin-left: 20px;
}
.demo-table-expand label {
  width: 100px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 100%;
}
</style>